package com.piece.core.mongo.properties;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;

@Data
@RefreshScope
@Configuration
@ConfigurationProperties(prefix = "spring.data.mongodb")
public class MongoProperties {

    /**
     * 地址，可集群模式
     */
    private String uri;

    private String database;

    private String username;

    private String password;

    private String replicaSet;

    /**
     * 线程最小连接数
     */
    private Integer minPoolSize = 1;

    /**
     * 线程最大连接数
     */
    private Integer maxPoolSize = 100;

    /**
     * 最大连接空闲时间
     */
    private Integer maxIdleTimeMs = 5;

    /**
     * 最大有效存活时间
     */
    private Integer maxLifeTimeMs = 10000;

    /**
     * 等待获取连接最大超时时间
     */
    private Integer waitQueueTimeoutMs = 5000;

    /**
     * 连接超时时间
     */
    private Integer connectTimeoutMs = 1000;

    /**
     * socket超时时间
     */
    private Integer socketTimeoutMs = 10000;

    /**
     * 是否启用ssl
     */
    private Boolean ssl = false;

    /**
     * 是否允许使用无效的主机名
     */
    private Boolean sslInvalidHostnameAllowed = false;

    /**
     * 心跳检测发送频率
     */
    private Integer heartbeatFrequencyMs = 20000;
}
